package errorx


var (
	ParamsError = NewBizError(1101,"参数错误")
 	InternalServerError = NewBizError(500,"服务器错误")
	FunctionUnableError = NewBizError(500,"功能未完成")
	GatewayError = NewBizError(500,"网关错误")
	Unauthorized = NewBizError(500,"权限不足")
	IllegalError = NewBizError(500,"非法操作")
	AuthNoFound = NewBizError(500,"未发现授权信息")
	UserUnexistError = NewBizError(500,"用户不存在异常")
	FileTypeNoAdaptError = NewBizError(500,"文件类型不匹配异常")
	FileParseError = NewBizError(500,"文件解析错误")
	TypeTransError = NewBizError(500,"类型转换异常")
	SqlUpdateError = NewBizError(500,"数据库数据更新异常")
	SqlInsertError = NewBizError(500,"数据库数据新增异常")
	SqlSearchError = NewBizError(500,"数据库数据查询异常")
	SqlDeleteError = NewBizError(500,"数据库数据删除异常")
	SqlExistError = NewBizError(500,"数据库数据不存在异常")
)

type BizError struct {
	Code int  `json:"code"`
	Message string  `json:"message"`
}

func NewBizError(code int,message string) *BizError{
	return &BizError{
		Code: code,
		Message: message,
	}
}

func (e *BizError)Error() string {

	return e.Message
}

type ErrorResponse struct{
	Code int  `json:"code"`
	Message string  `json:"message"`
}

func (e *BizError)Data() *ErrorResponse{
	return &ErrorResponse{
		e.Code,
		e.Message,
	}
}
